Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

396
Views
"setColumnDefs" is not working on version 26.1.0 (Angular)

I have an angular project that uses Ag-Grid and here is my problem.

I thing that I have tried all that is in my hand but I'm not able to make it work... My code needs to add and remove some Columns dynamically, and in the documentation I saw that setColumnDefs from the GridApi was a good idea to try it.

I don't know If I'm doing something wrong, but I tried to follow the docs as much as I can.

This is the method that updates the columns definitions (it doesn't work)

updateColumnsMode(): void {
  if(!this.showAdvancedColumns) {
    this.gridOptions
        .api!
        .setColumnDefs(this.buildColumns(this.advancedColumnsName)));
  } else {
    this.gridOptions
        .api!
        .setColumnDefs(this.buildColumns(this.normalColumnsName)));
  }
}

My grid Options

gridOptions: GridOptions = {
  rowData: this.rowData,
  columnDefs: this.buildColumns(this.normalColumnsName),
  onGridReady: (event:any) => console.log("Grid working!"),
}

And the api initialization

onGridReady(params: any) {
  this.gridApi = params.api;
  this.gridColumnApi = params.columnApi;
}

And if it could be relevant, the method where I build the columns

buildColumns(columnsToBuild: String[]): ColDef[] {
  return columnsToBuild.map((column):any => {
    return { "field": column, sortable: true, filter: true }
  });
}

The columnsToBuild is jut an array of String.

I really need help with this guys.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!